﻿
/*
EC-IDE class, from default dom template,
	AppEntry
	AppEntry

Author:

All Rights Reserved

LICENSE:

Created: 2008-12-10 15:56:58

Updated:

*/

//#EC_PARAM {param:'n'}

$ec.$preload(
	"AppEntry",
	function()
	{
		this.prototype= {
//////////////////////////////
// EC-CLASS BODY
//////////////////////////////
			
			eid: "",    //binding element id
			oEditor: null,
			
			AppEntry: function( e, p )  //ec-class constructor
			{
				this.eid= $ec.$eid(e);      //assign and get unique element id
				this.oEditor= $ec( $ec(this.eid,"divEditor" ) );
				this.oEditor.CreateToolbar( $ec(this.eid,"divTool" ) );
				
				this.oEditor.AddRule($ec.$import("org.supertree.editor.RuleHtml").prototype);
				this.oEditor.AddRule($ec.$import("org.supertree.editor.RuleJavascript").prototype);
				this.oEditor.AddRule($ec.$import("org.supertree.editor.RuleXslt").prototype);
				
				this.RulehtmClick();
			},
			
			
			RulehtmClick: function(evt)
			{
				var e= $ec(this.eid);
				
				this.oEditor.SetRule("Html");

				this.oEditor.SetText($ec(this.eid,"txtData3").value);

			},
			
			RulejsClick: function(evt)
			{
				var e= $ec(this.eid);
				
				this.oEditor.SetRule("Javascript");

				this.oEditor.SetText($ec(this.eid,"txtData2").value);
			},
			
			RulexsltClick: function(evt)
			{
				var e= $ec(this.eid);
				
				this.oEditor.SetRule("Xslt");

				this.oEditor.SetText($ec(this.eid,"txtData").value);
			},
			
			TestruleClick: function(evt)
			{
				var e= $ec(this.eid);
				
				var r=
				{
					sName: "Self-defined",
					sEndStack:"|0|",
					rule: eval($ec(this.eid,"txt_r").value)
				};
				
				$ec.$import("org.supertree.editor.RuleCompiler").prototype.Compile(r);
				
				if( this.oEditor.aRule.length>4 )
				{
					this.oEditor.aRule[4][0]= r;
				}
				else
				{
					this.oEditor.AddRule(r);
				}
				
				this.oEditor.SetRule( "Self-defined" );
				this.oEditor.SetText($ec(this.eid,"txt_t").value);
			}
			
//////////////////////////////
// END EC-CLASS BODY    //NOTE - DO NOT CHANGE THESE 3 LINES, the ide wizards may use them.
//////////////////////////////
		};
		
		//#EC_RES
		this.$res=["",1,"htmi_AppEntry" ];
		//#HTMI: htmi_AppEntry, AppEntry.htmi
		//#END_EC_RES
		
		//#EC_MAP
		this.$map=[
			["rulehtm","click","RulehtmClick"],
			["rulejs","click","RulejsClick"],
			["rulexslt","click","RulexsltClick"],
			["testrule","click","TestruleClick"]
			];
		//#END_EC_MAP
		
	}
);
